<template>
	<view class="container">
		<!-- 顶部导航 -->
		<view class="top-section">
			<view class="top-title">
				<view class="city-selector" @tap="onSelectCity">
					<image class="arrow-icon" src="/static/user/location.png"></image>
					<text class="city-name">{{cityname}}</text>
					<image class="arrow-icon1" src="/static/user/arrow_down.png"></image>
				</view>
				<view class="app-name-box" @tap="toscan">
					<image class="icon" src="/static/icons/fujiajia.png"></image>
					<!-- <text class="app-name">付加加</text>
					<text class="app-pinyin">Fu Jia Jia</text> -->
				</view>
			</view>
			<view class="search-bar-box">
				<input class="search-bar" model="searchtext" @tap="goSearch()" placeholder="搜索商家" />
			</view>
		</view>

		<view class="nav-background">
			<!-- 导航分类 -->
			<view class="nav-category">
				<view v-for="(tab, index) in cateory" :key="index"
					:class="['tab-item', { active: selectedTab === index }]" @click="selectTab(index)">
					{{ tab.title }}
				</view>
			</view>

			<!-- 内容区域 -->
			<view class="tab-content">
				<view class="grid">
					<!-- tabContent[selectedTab] -->
					<!-- {{cateory[selectedTab]['child']}} -->
					<view @tap="goMenu(item.id)" v-for="(item, index) in cateory[selectedTab].child" :key="index"
						class="grid-item">
						<image :src="item.thumb" class="item-image" />
						<text class="item-text">{{ item.title }}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="free-section" @tap="goNav('https://h5.yycjkb.cn/#/?merid=1&custom_param=1111')">
			<image class="upgrade-image" src="/static/user/free.png" />
		</view>
		<!-- 本地生活优惠 -->
		<view class="local-life">

			<!-- <view class="section-title">本地生活 <text class="discount-text">最高可省50%</text></view> -->
			<view class="section-title">
				<!-- 左侧图片 -->
				<image class="icon" src="/static/icons/nearby.png"></image>

				<!-- 滚动容器 -->
				<view class="scroll-box">
					<view class="scroll-container">
						<view class="scroll-wrapper">
							<!-- 原始内容 -->
							<view class="scroll-item" v-for="(item, index) in textList" :key="'original-' + index">
								{{ item }}
							</view>
							<!-- 复制内容，用于无缝滚动 -->
							<view class="scroll-item" v-for="(item, index) in textList" :key="'copy-' + index">
								{{ item }}
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 卡片容器：三列布局 -->
			<view class="card-container">
				<!-- Left Column -->
				<view class="left-column">
					<view class="card" v-if="index<2" v-for="(item, index) in taokeList" :key="index">
						<image @tap="goNav(item.url)" :src="item.thumb" class="card-icon" />
					</view>
				</view>

				<!-- Middle Column -->
				<view class="middle-column">
					<view class="card" v-if="index>1 && index<4" v-for="(item, index) in taokeList" :key="index">
						<image @tap="goNav(item.url)" :src="item.thumb" class="card-icon" />
					</view>
				</view>

				<!-- 右侧新增列 -->
				<view class="right-column">
					<view class="new-row" @tap="goNav(item.url)" v-if="index>3 && index<8"
						v-for="(item, index) in taokeList" :key="index">
						<!-- 左侧文字 -->
						<view class="text-box">
							<text class="title-text">{{ item.title }}</text>
							<text class="subtitle-text">{{ item.title }}</text>
						</view>
						<!-- 右侧图片 -->
						<image :src="item.thumb" class="row-image" />
					</view>
				</view>
			</view>
		</view>

		<!-- 附近商家 -->
		<view class="store-list">
			<!-- <view class="section-title">附近商家 <text class="discount-text">最高可省50%</text></view> -->

			<view class="section-title">
				<image src="/static/icons/local.png"></image>
			</view>
			<view class="store-item" v-for="(store, index) in shops" :key="index">
				<!-- {{store}} -->
				<view class="store-image" @tap="toShop(store.id)">
					<image mode="aspectFill" :src="store.logo"></image>
				</view>
				<view class="store-details" @tap="toShop(store.id)">
					<view class="row">
						<image class="gif-image" src="/static/red.gif" mode="aspectFit"></image>
						<text class="store-name">{{ store.short_name }}</text>
					</view>
					<view class="store-info">
						<image class="tel-icon" src="/static/user/tel.png"></image>
						<text class="tel-number">{{ store.tel }}</text>
					</view>
					<view class="discount-container">
						<image class="discount-icon" src="/static/icons/4.png"></image>
						<text class="discount-text">让利</text><text class="discount-fee">{{store.discount}}%</text>
					</view>
				</view>
				<view class="navigate-container">
					<image class="navigate-icon" src="/static/user/navigate.png" mode="aspectFit" />
					<text class="navigate-text">{{store.distance}}</text>
					<!-- <button class="navigate-button" @tap="goMap(store)">导航</button> -->
				</view>
			</view>
		</view>
		<template v-if="userInfo.id>0 && money>0">
			<gcm-red-bag :money="money" :options="redBagConfig" @onConfirm="onConfirm" @onClose="onClose"
				@onCover="onCover"></gcm-red-bag>
		</template>
	</view>
</template>

<style lang="scss" scoped>
	.free-section {
		margin: 20rpx 0;
		text-align: center;
		position: relative;

		image {
			width: 95%;
			/* 图片宽度为父容器的 80% */
			// min-width: 750px;
			/* 最大宽度不超过 750px */
			height: 60px;
			/* 高度自适应 */
		}
	}


	/* 页面整体容器 */
	.container {
		background-color: #f5f5f5;
		font-family: Arial, sans-serif;
	}




	/* 顶部导航 */
	.top-section {
		height: 130px;
		background-color: #ff6600;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		position: relative;
		/* 为伪元素定位 */
	}

	.search-bar-box {
		display: flex;
		justify-content: center; // 水平居中
		align-items: center; // 垂直居中
		width: 100%; // 确保可以按需扩展
	}

	.search-bar {
		margin-top: 30rpx;
		padding: 35rpx;
		border-radius: 50rpx;
		background-color: #fff;
		width: 340px;
	}

	.top-title {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		position: relative;
		/* Allows positioning the city-selector */
	}

	.city-selector {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		position: absolute;
		left: 10px;
		/* Adjust as needed for desired spacing */
		cursor: pointer;
	}

	.city-selector .arrow-icon {
		width: 16px;
		height: 16px;
		margin: 0 5px;
	}

	.city-selector .arrow-icon1 {
		width: 16px;
		height: 10px;
		margin: 0 5px;
	}

	.city-name {
		font-size: 16px;
		color: #fff;
	}

	.app-name-box {
		display: flex;
		flex-direction: column;
		align-items: center;

		image {
			width: 90px;
			height: 30px;
		}
	}

	.app-name {
		font-size: 20px;
		font-weight: bold;
		color: #fff;
	}

	.app-pinyin {
		font-size: 14px;
		color: #fff;
	}

	.nav-background {
		background-color: #ff6600;
		padding-bottom: 6rpx;
	}

	/* 导航分类容器 */
	.nav-category {
		display: flex;
		justify-content: space-between;
		/* background-color: #f5f5f5; */
		// padding: 10px;
		border-radius: 8px;
		padding: 10px;
		/* box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); */
	}

	/* 单个 Tab 样式 */
	.tab-item {

		// flex: 1;
		text-align: center;
		padding: 5px 0;
		// background-color: #f5f5f5;
		color: #fff;
		border-radius: 15px;
		font-size: 14px;
		// transition: background-color 0.3s, color 0.3s;
		width: 60px;
	}

	.tab-item.active {
		background-color: #ffffff;
		color: #ff4500;
		font-weight: bold;
		box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
	}

	/* 内容区域 */
	.tab-content {
		background-color: #fff;
		/* 整体背景颜色 */
		border-radius: 10px;
		padding: 10px;
		margin: 10px;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	}

	/* 网格容器 */
	.grid {
		display: grid;
		grid-template-columns: repeat(5, 1fr);
		/* 每行 5 列 */
		justify-items: center;
		/* 水平居中 */
		align-items: center;
		/* 垂直居中 */
		gap: 10px;
		/* 每项之间的间距 */
	}

	/* 单个格子样式 */
	.grid-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		text-align: center;
		/* 居中文本对齐 */
	}

	/* 图片样式 */
	.item-image {
		width: 50px;
		height: 50px;
		margin-bottom: 8px;
	}

	/* 文字样式 */
	.item-text {
		font-size: 12px;
		color: #333;
	}

	/* 本地生活 */
	.local-life {
		margin: 10px;
	}

	.section-title {
		display: flex;
		align-items: center;
		/* 垂直居中 */
		padding: 10px;
		gap: 10px;
		/* 图片和滚动框之间的间距 */
	}

	.icon {
		width: 24px;
		/* 图片宽度 */
		height: 24px;
		/* 图片高度 */
	}

	.scroll-box {
		flex: 1;
		/* 滚动框占据剩余空间 */
		overflow: hidden;
		/* 隐藏超出内容 */
		position: relative;
		background-color: rgba(141, 142, 144, 0.8);
		/* 背景颜色 */
		border-radius: 15px;
		/* 圆角 */
		color: white;
		/* 滚动文字颜色 */
		height: 30px;
		/* 滚动框高度 */
	}

	.scroll-container {
		position: relative;
		width: 100%;
		overflow: hidden;
		/* 隐藏超出部分 */
		height: 100%;
		/* 高度与滚动框一致 */
	}

	.scroll-wrapper {
		display: flex;
		flex-direction: column;
		/* 子项垂直排列 */
		animation: scroll-up 15s linear infinite;
		/* 无缝滚动动画 */
	}

	.scroll-item {
		padding: 10px;
		/* 滚动项的内边距 */
		font-size: 14px;
		text-align: center;
		/* 文字居中 */
		white-space: nowrap;
		/* 禁止换行 */
	}

	/* 向上滚动动画 */
	@keyframes scroll-up {
		0% {
			transform: translateY(0);
			/* 从初始位置开始 */
		}

		100% {
			transform: translateY(-100%);
			/* 滚动一整组内容 */
		}
	}



	.section-title {
		font-weight: bold;
		font-size: 16px;
		margin: 10px 0;

		image {
			height: 28px;
			width: 180px;
		}
	}

	.discount-text {
		color: #ff4500;
		font-size: 12px;
	}

	/* 卡片容器：三列布局 */
	/* Ensure the card container's columns are full-height and background-sized */
	.card-container {
		display: flex;
		justify-content: space-between;
		// margin: 10px;
		// background-color: #ffffff;
	}

	/* Adjust the left and middle column to fill the space */
	.left-column,
	.middle-column {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	/* Make the images fill their container */
	.card {
		position: relative;
		width: 100%;
		height: 100%;
		/* Ensures it takes up the full height of its parent */
		display: flex;
		align-items: center;
		justify-content: center;
		overflow: hidden;
		padding: 2px;
	}

	/* Style the card image to cover the entire card */
	.card-icon {
		width: 100%;
		height: 100%;
		object-fit: cover;
		/* Ensures it scales correctly */
	}


	.card-text {
		font-size: 14px;
	}

	/* 右侧新增列 */
	.right-column {
		flex: 2;
		/* 右侧占用50%宽度 */
		display: flex;
		flex-direction: column;
		gap: 5px;
	}

	/* 右侧每行 */
	.new-row {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: white;
		padding: 10px;
		border-radius: 8px;
		box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
	}

	/* 新增列中文字和图片 */
	.text-box {
		display: flex;
		flex-direction: column;
	}

	.title-text {
		font-weight: bold;
		font-size: 14px;
	}

	.subtitle-text {
		font-size: 12px;
		color: gray;
	}

	.row-image {
		width: 50px;
		height: 50px;
		margin-left: 10px;
		border-radius: 5px;
	}

	.store-list {
		margin: 20rpx;

	}

	.row {
		display: flex;
		flex-direction: row;
		/* 设置横向排列 */
		align-items: center;
		/* 垂直方向居中 */
	}

	.gif-image {
		width: 60rpx;
		/* 根据需求设置图片大小 */
		height: 60rpx;
		margin-right: 10rpx;
		/* 图片和文字之间的间距 */
	}

	.store-name {
		font-size: 28rpx;
		color: #333;
	}

	.store-item {
		background-color: #fff;
		display: flex;
		align-items: center;
		// background-color: #fff;
		// color: #FC7130;
		font-weight: 900;
		padding: 20rpx;
		border-radius: 15rpx;
		margin-bottom: 15rpx;
	}

	.store-image {
		// background-color: #ffcc80;
		/* width: 200rpx;
		height: 50rpx; */
		margin-right: 20rpx;
		text-align: center;
		/* line-height: 100rpx; */
		border-radius: 20rpx;
		// box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
		/* 添加阴影效果 */

		image {
			width: 140rpx;
			height: 140rpx;
			border-radius: 20rpx;
		}
	}

	.store-details {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
		height: 25px;
		line-height: 25px;
	}

	.store-info {
		display: flex;
		align-items: center;
		font-size: 14px;
		color: #666;
		margin-bottom: 5px;
	}

	.tel-icon {
		width: 16px;
		height: 16px;
		margin-right: 5px;
	}

	.tel-number {
		font-size: 14px;
		color: #333;
	}

	/* 优惠容器样式 */
	.discount-container {
		display: flex;
		align-items: center;
		// margin-top: 10px;
	}

	/* 图标样式 */
	.discount-icon {
		width: 20px;
		height: 25px;
		background-color: #ff4500;
		/* 图标背景色 */
		// border-radius: 50%;
		/* 圆形图标 */
		display: flex;
		justify-content: center;
		align-items: center;
		margin-left: 5px;
	}

	/* 优惠文字样式（带背景色） */
	.discount-text {
		font-size: 12px;
		color: #11100F;
		/* 文字颜色 */
		background-color: #FFF2DE;
		padding-left: 5px;
		/* 背景色 */
		// padding: 0px 0px 5px 0px;
		/* 内边距，控制背景区域大小 */
		// border-radius: 8px;
		/* 圆角 */

	}

	.discount-fee {
		background-color: #FFF2DE;
		color: #FD737C;
		padding: 0 5px;

		// padding: 5px;
	}

	/* 导航按钮、文字和图标容器 */
	.navigate-container {
		display: flex;
		flex-direction: column;
		align-items: center;
		/* 水平居中 */
		margin-top: 15px;

	}

	.navigate-icon {
		width: 20px;
		height: 20px;
		margin-bottom: 5px;
		/* 图标和文字之间的间距 */
	}

	.navigate-text {
		font-size: 12px;
		color: #333;
		margin-bottom: 5px;
		/* 和按钮的间距 */
	}

	.navigate-button {
		width: 80px;
		height: 25px;
		background-color: #302E2D;
		color: #fff;
		font-size: 14px;
		text-align: center;
		border-radius: 5px;
		border: none;
		line-height: 25px;
		/* 使按钮文字垂直居中 */
	}
</style>



<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import api from "@/api/";
	import user from "@/api/user";
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	import MyHomeHeader from "@/components/MyHomeHeader";
	import MyHomeSlide from "@/components/MyHomeSlide";
	import MyHomeMenus from "@/components/MyHomeMenus";
	import MyTaokeMenus from "@/components/MyTaokeMenus";
	import MyShops from "@/components/MyShops";
	// import TaokeList from "@/components/TaokeList";
	import {
		Base64
	} from "@/common/base64.js"
	export default {
		data() {
			return {
				money: 0,
				redBagConfig: {
					btnText: "确认收款",
				},
				// Tab 数据
				tabs: [{
						name: "全部"
					},
					{
						name: "饮品"
					},
					{
						name: "休闲娱乐"
					},
					{
						name: "电影"
					},
					{
						name: "购物"
					},
				],

				// 当前选中的 Tab 下标
				selectedTab: 0,

				// 每个 Tab 对应的内容
				tabContent: [
					// Tab 1 内容
					[{
							image: "/static/icons/food1.png",
							text: "火锅"
						},
						{
							image: "/static/icons/food2.png",
							text: "烧烤"
						},
						{
							image: "/static/icons/food3.png",
							text: "中餐"
						},
						{
							image: "/static/icons/food4.png",
							text: "日料"
						},
						{
							image: "/static/icons/food5.png",
							text: "甜品"
						},
					],
					// Tab 2 内容
					[{
							image: "/static/icons/drink1.png",
							text: "奶茶"
						},
						{
							image: "/static/icons/drink2.png",
							text: "咖啡"
						},
						{
							image: "/static/icons/drink3.png",
							text: "果汁"
						},
						{
							image: "/static/icons/drink4.png",
							text: "气泡水"
						},
						{
							image: "/static/icons/drink5.png",
							text: "酒类"
						},
					],
					// Tab 3 内容
					[{
							image: "/static/icons/relax1.png",
							text: "KTV"
						},
						{
							image: "/static/icons/relax2.png",
							text: "密室"
						},
						{
							image: "/static/icons/relax3.png",
							text: "桌游"
						},
						{
							image: "/static/icons/relax4.png",
							text: "SPA"
						},
						{
							image: "/static/icons/relax5.png",
							text: "健身"
						},
					],
					// Tab 4 内容
					[{
							image: "/static/icons/movie1.png",
							text: "动作片"
						},
						{
							image: "/static/icons/movie2.png",
							text: "喜剧片"
						},
						{
							image: "/static/icons/movie3.png",
							text: "科幻片"
						},
						{
							image: "/static/icons/movie4.png",
							text: "爱情片"
						},
						{
							image: "/static/icons/movie5.png",
							text: "悬疑片"
						},
					],
					// Tab 5 内容
					[{
							image: "/static/icons/shopping1.png",
							text: "服饰"
						},
						{
							image: "/static/icons/shopping2.png",
							text: "数码"
						},
						{
							image: "/static/icons/shopping3.png",
							text: "家电"
						},
						{
							image: "/static/icons/shopping4.png",
							text: "家具"
						},
						{
							image: "/static/icons/shopping5.png",
							text: "百货"
						},
					],
				],

				// 左侧列数据
				leftCards: [{
						title: '美团',
						subtitle: '最高领66元',
						image: '/static/icons/pin.png'
					},
					{
						title: '饿了么',
						subtitle: '最高领66元',
						image: '/static/icons/pin.png'
					},
				],

				// 中间列数据
				middleCards: [{
						title: '京东',
						subtitle: '最高省50%',
						image: '/static/icons/pin.png'
					},
					{
						title: '拼多多',
						subtitle: '最高省50%',
						image: '/static/icons/pin.png'
					},
				],

				// 右侧列新增的数据
				rightCards: [{
						title: '加油优惠',
						subtitle: '直降2.7元/升',
						image: '/static/icons/tab-1.png'
					},
					{
						title: '电影特惠',
						subtitle: '低至6折',
						image: '/static/icons/tab-2.png'
					},
					{
						title: '出行优惠',
						subtitle: '打车立减10元',
						image: '/static/icons/tab-3.png'
					},
					{
						title: '快递省钱',
						subtitle: '低至5元寄件',
						image: '/static/icons/tab-4.png'
					},
				],
				// 商家列表
				shops: [{
						image: '/static/images/shop1.jpg',
						name: '福帅食品经营部',
						distance: 0.7,
						discount: 11,
					},
					{
						image: '/static/images/shop2.jpg',
						name: '华南超市',
						distance: 1.2,
						discount: 15,
					},
				],
				textList: [], // 要滚动的文字
				money: 0,
				redBagConfig: {
					btnText: "确认收款",
				},
				taokeList: new Array(10).fill({}),
				slides: [{
					thumb: '../../../static/default.png'
				}],
				cateory: new Array(10).fill({}),
				sortType: 0,
				shops: [],
				page: 1,
				more: 'more',
				flag: false,
				locationRes: {
					longitude: 0,
					latitude: 0,
				},
				navList: [],
				goodsList: [],
				searchText: '',
				cityname: '厦门市'
			};
		},
		computed: {
			...mapState(['userLocation', 'userInfo', 'hasLogin']),
		},
		components: {
			MyHomeHeader,
			MyHomeSlide,
			MyHomeMenus,
			MyTaokeMenus,
			MyShops,
			uniLoadMore,
			// TaokeList
		},
		onUnload() {
			// 页面卸载时移除事件监听
			uni.$off('citynameChanged');
		},
		onShow() {
			let that = this
			// this.cityname = uni.getStorageSync('cityname')
			// alert(this.cityname);
			// 监听全局事件

			uni.$on('citynameChanged', (newCityname) => {
				this.shops = [];
				this.cityname = newCityname;
				// alert('城市名称已更新：' + this.cityname);
				this.getShops();
			});

			uni.showModal({
				title: '紧急声明',
				content: "尊敬的付加加用户：\n由于附加加近期发展太快,导致被同行恶意投诉。公司法务部在做紧急申诉处理。\n敬请大家放心,付加加业务合情合法合理。公司现启动APP预案,一切业务正常有序进行。\n申诉流程完成后,会第一时间告知广大用户。\n付加加运营中心\n2025年3月15日 "
			});
		},
		onLoad(params) {


			this.page = 1;

			if (params.cid) {
				this.$store.commit('setInviteCode', params.cid);
			}
			// console.log(this.$store.state.inviteCode);
			this.loadIndex();
			this.getCateory();
			this.getTaoke();
			this.getOrders();
			this.getShops();
			this.loadNav();
			this.getDistribute()
		},
		onReachBottom() {
			if (this.more !== 'noMore') {
				this.more = 'loading'
				this.page++;
				this.getShops();
			}
		},
		onPageScroll(e) {
			if (e.scrollTop > 600) { //当距离大于600时显示回到顶部按钮
				this.flag = true
			} else { //当距离小于600时隐藏回到顶部按钮
				this.flag = false
			}
		},
		methods: {
			onSelectCity() {
				uni.navigateTo({
					url: '/pages/gjs-selectCity/gjs-selectCity'
				})
			},
			toscan() {
				uni.navigateTo({
					url: '/pages/home/scan/scan'
				})
			},
			// 点击确认红包按钮事件
			onConfirm() {},
			// 关闭红包时触发
			onClose() {},
			// 开启红包时触发
			onCover() {
				if (!this.userInfo.id) {
					uni.navigateTo({
						url: '/pages/my/login'
					})
					return;
				}
				// api/user_Vip/distribute

			},
			goSearch() {
				uni.navigateTo({
					url: `/pages/home/search?keyword=` + this.searchText.trim()
				})
			},
			selectTab(index) {
				this.selectedTab = index;
			},
			goMenu(cid) {
				uni.navigateTo({
					url: `/pages/home/list?cid=${cid}`
				})
			},
			goNav(url) {
				// #ifdef H5
				location.href = url
				// #endif

				// #ifdef APP-PLUS

				plus.runtime.openUrl(url)

				// #endif

				// uni.navigateTo({
				// 	url: `/pages/home/list?cid=${cid}`
				// })
			},
			async goMap(shops) {
				if (!shops.lat || !shops.lng) {
					return this.toast('商家暂未设置导航');
				}
				const [err, res] = await uni.openLocation({ //​使用微信内置地图查看位置。
					latitude: parseFloat(shops.lat), //要去的纬度-地址
					longitude: parseFloat(shops.lng), //要去的经度-地址
					name: shops.short_name || shops.title,
					address: shops.address
				})
				if (err) {
					this.toast(err.errMsg)
				}
			},
			toShop(id) {
				uni.navigateTo({
					url: '/pages/home/detail?id=' + id
				})
			},
			// 点击确认红包按钮事件
			onConfirm() {},
			// 关闭红包时触发
			onClose() {},
			// 开启红包时触发
			onCover() {
				if (!this.userInfo.id) {
					uni.navigateTo({
						url: '/pages/my/login'
					})
					return;
				}
				// api/user_Vip/distribute

			},
			getDistribute() {
				let that = this

				user.distribute({
					user_id: that.userInfo.id
				}).then(res => {
					console.log(res.code)
					if (res.code === 1) {
						that.money = res.data.amount;
					} else {
						// that.toast(res.msg);
					}
				})
			},
			onSkip(id) {

				// #ifdef APP-PLUS
				plus.runtime.openURL('https://www.yycjkb.cn/dist/#/pages/product/goods?id=' + id)
				// #endif

				// #ifdef H5
				location.href = 'https://www.yycjkb.cn/dist/#/pages/product/goods?id=' + id
				// #endif


				// 
			},
			tonav(index) {

				let nav = '';
				if (index == 1) {
					nav = this.navList.nav1;
				}

				if (index == 2) {
					nav = this.navList.nav2;
				}

				if (index == 3) {
					nav = this.navList.nav3;
				}

				if (index == 4) {
					nav = this.navList.nav4;
				}

				uni.navigateTo({
					url: '/pages/web/index?url=' + Base64.encode(nav)
				})
			},
			async loadNav() {
				api.navList().then(res => {
					if (res.code === 1) {
						this.navList = res.data.navlist;
					} else {
						this.toast(res.msg);
					}
				});
				// https://www.yycjkb.cn/api/wanlshop/product/likes?page=1
				api.likes().then(res => {
					if (res.code === 1) {
						this.goodsList = res.data.data;
					} else {
						this.toast(res.msg);
					}
				})
			},
			async loadIndex() {
				api.index().then(res => {
					if (res.code === 1) {
						this.slides = res.data.list;
					} else {
						this.toast(res.msg);
					}
				});
			},
			async getCateory() {
				let res = await api.homecateList()
				if (res.code == 1) {
					this.cateory = res.data.list
				}
			},
			async getTaoke() {
				let res = await api.taokeList()
				if (res.code == 1) {
					this.taokeList = res.data.list
				}
			},
			async getOrders() {
				let res = await api.orderList()
				if (res.code == 1) {
					this.textList = res.data.list.map(item => item.txt);
				}
			},
			async getShops(type) {
				var that = this;
				// await this.$store.dispatch('getLocation');
				await uni.getLocation({
					success(result) {
						that.locationRes.latitude = result.latitude // 将纬度存起来
						that.locationRes.longitude = result.longitude // 将经度存起来

						api.shopList({
							cityname: that.cityname,
							recommend: 1,
							page: that.page,
							sortType: that.sortType,
							lng: that.locationRes.longitude,
							lat: that.locationRes.latitude
						}).then(res => {
							if (res.code == 1) {
								if (res.data.list.length <= 0) {
									that.more = 'noMore';
								} else {
									that.more = 'more';
								}
								that.shops = type ? res.data.list : that.shops.concat(res.data.list)
							}
						})

					},
					fail: error => {
						console.log("获取定位失败了", error)
						api.shopList({
							page: that.page,
							sortType: that.sortType,
							lng: 0,
							lat: 0
						}).then(res => {
							if (res.code == 1) {
								if (res.data.list.length <= 0) {
									that.more = 'noMore';
								} else {
									that.more = 'more';
								}
								that.shops = type ? res.data.list : that.shops.concat(res.data
									.list)
							}
						})
					}
				})


			},
			backTop() {
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 200
				});
			},
			switchTab(sortType) {
				this.sortType = sortType;
				this.page = 1;
				this.getShops('change');
			}
		}
	};
</script>